package com.cnap.model.strategy.schedule;

import cn.hutool.core.text.CharSequenceUtil;
import com.cnap.model.stage.StageTypeEnum;
import com.cnap.model.strategy.SvcConstants;

/**
 * 业务场景二级分类
 *
 * @author xc
 **/
public enum SvcTypeEnum {
    WEB_SERVICE("前端服务器", SvcCategoryEnum.WEB.getSvcCategory(), SvcConstants.CPU),
    FILE_SERVICE("文件服务器", SvcCategoryEnum.DATABASE.getSvcCategory(), SvcConstants.CPU),
    DATABASE_SERVICE("数据库", SvcCategoryEnum.DATABASE.getSvcCategory(), SvcConstants.CPU),
    AI_TRAIN("AI训练", SvcCategoryEnum.AI.getSvcCategory(), SvcConstants.GPU),
    AI_ILLATION("AI推理", SvcCategoryEnum.AI.getSvcCategory(), SvcConstants.CPU),
    ;
    /**
     * 二级分类
     */
    private final String svcType;
    /**
     * 一级分类
     */
    private final String parentCategory;
    /**
     * 类型，CPU/GPU
     */
    private final String detailType;

    SvcTypeEnum(String svcType, String parentCategory, String detailType) {
        this.svcType = svcType;
        this.parentCategory = parentCategory;
        this.detailType = detailType;
    }

    /**
     * get
     *
     * @return SvcType
     */
    public String getSvcType() {
        return svcType;
    }

    /**
     * get
     *
     * @return ParentCategory
     */
    public String getParentCategory() {
        return parentCategory;
    }

    /**
     * get
     *
     * @return DetailType
     */
    public String getDetailType() {
        return detailType;
    }

    /**
     * 根据svcType查询枚举
     *
     * @param svcType svcType
     * @return 枚举
     */
    public static SvcTypeEnum getSvcTypeEnumBySvcType(String svcType) {
        if (CharSequenceUtil.isEmpty(svcType)) {
            return null;
        }
        SvcTypeEnum[] svcTypeEnums = SvcTypeEnum.values();
        for (SvcTypeEnum stageTypeEnum : svcTypeEnums) {
            if (stageTypeEnum.getSvcType().equals(svcType)) {
                return stageTypeEnum;
            }
        }
        return null;
    }
}
